package com.ict.bills.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ict.bills.utils.DataGridView;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.ict.bills.mapper.BillsMapper;
import com.ict.bills.domain.Bills;
import com.ict.bills.service.BillsService;

import java.util.List;

/**
 * @Author: Lizbeth9421
 * @Date: 2021/10/10/0:47
 */
@Service
public class BillsServiceImpl implements BillsService{

    @Resource
    private BillsMapper billsMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return billsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Bills record) {
        return billsMapper.insert(record);
    }

    @Override
    public int insertSelective(Bills record) {
        return billsMapper.insertSelective(record);
    }

    @Override
    public Bills selectByPrimaryKey(Integer id) {
        return billsMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Bills record) {
        return billsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Bills record) {
        return billsMapper.updateByPrimaryKey(record);
    }


    /**
     * 加载所有账单信息
     *
     * @return
     */
    @Override
    public DataGridView loadAllBills(Bills bills) {
        PageHelper.startPage(bills.getPage(), bills.getLimit());
        PageInfo<Bills> pageinfo = new PageInfo<>(this.billsMapper.loadAllBills(bills));
        return new DataGridView(pageinfo.getTotal(), pageinfo.getList());
    }

}
